using System;
using Indiefreaks.AceOnSteroids.Menus;
using Indiefreaks.Xna.Core;
using Indiefreaks.Xna.Rendering;
using Indiefreaks.Xna.Rendering.Gui;
using Microsoft.Xna.Framework.Content;

namespace Indiefreaks.AceOnSteroids.Layers.MainMenu
{
    /// <summary>
    /// The MainMenuLayer hosts the GUI elements that will compose the whole menu
    /// </summary>
    public class MainMenuLayer : Layer, IContentHost
    {
        private readonly RootMainMenu _rootMainMenu;

        /// <summary>
        /// Creates a new instance
        /// </summary>
        /// <param name="gameState">The GameState instance this Layer will be added to</param>
        public MainMenuLayer(GameState gameState) : base(gameState)
        {
            // we create our root main menu instance
            _rootMainMenu = new RootMainMenu();
            // we add it to the GuiManager so that it gets updated and rendered
            Application.SunBurn.GetManager<GuiManager>(true).AddScreen(_rootMainMenu);
            // and we set the input focus to it
            _rootMainMenu.SetFocus();
        }

        #region Implementation of IContentHost

        public void LoadContent(IContentCatalogue catalogue, ContentManager manager)
        {
            // by adding the rootMainMenu instance to the catalogue, we'll get its inner buttons also added automatically. They'll all get loaded when required.
            catalogue.Add(_rootMainMenu);
        }

        public void UnloadContent(IContentCatalogue catalogue)
        {
        }

        #endregion
    }
}